/**
 * Controller class for handling Return module
 */
package rentReturnController;

import java.net.URL;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.ResourceBundle;

import constants.Constants;
import javafx.collections.FXCollections;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import paymentEntity.CashEntity;
import paymentEntity.CreditCardEntity;
import pdf.PDFGenerator;
import rentReturnEntity.AdditionalEquipment;
import rentReturnEntity.RentEntity;
import rentReturnEntity.ReturnCostEntity;
import rentReturnEntity.ReturnEntity;
import rentReturnLogic.ReturnLogic;
import reservationEntity.ReservationEntity;
import userController.Navigator;
import userEntity.MembershipEntity;
import validator.Validator;

/**
 * @author Yokesh Kumar
 *
 */
public class ReturnController implements Initializable{

	private static RentEntity rentEntity = null;
	private static ReturnEntity returnEntity = null;
	private static ReturnCostEntity returnCostEntity = null;
	private static ReturnLogic returnLogic = null;
	private static MembershipEntity member = null;
	private static CreditCardEntity paymentInfo = null;
	private static CashEntity cashEntity = null;
	private static int returnId = 0;
	private static int sceneNumber = 0;
	private static int pointsPerDay = 0;

	/**
	 * Initial screen UI Elements
	 */
	@FXML
	private TextField return_RentID;
	@FXML
	private TextField return_RentedVehicleID;
	@FXML
	private Label return_InitialScreenRequiredFieldsLabel;
	@FXML
	private TextField return_FueltobeFilled; 
	@FXML
	private Label return_fueltobeFilledLabel;
	@FXML
	private Label return_InitialScreenFieldscontainSpacesLabel;
	@FXML
	private ComboBox<String> return_PaymentType;
	@FXML
	private TextField return_RentedDate;
	@FXML
	private TextField return_RentedTime;
	@FXML
	private TextField return_RentedOdometerReading;

	/**
	 * 2nd screen UI Elements
	 */
	private String returnVehicleCondition = null;
	private  static int rentedVehicleId = 0;
	private int reserveId = 0;
	private String return_time = null;
	private Integer return_odoReading = null;
	private boolean gasTankNotFull = false;
	private boolean isRoadstar = false;
	private double damageCost = 0.00;
	private double fueltobeFilled = 0.00;
	private static double totalamount = 0.00;
	private static double amountGivenbyCust = 0.00;
	private static int paymentID = 0;

	@FXML
	private ComboBox<Integer> return_ReturnHH;
	@FXML
	private ComboBox<Integer> return_ReturnMM;
	@FXML
	private TextField return_OdometerReading;
	@FXML
	private RadioButton return_GasTankFull;
	@FXML
	private RadioButton return_GasTankNotFull;
	@FXML
	private TextArea return_VehicleCondition;
	@FXML
	private TextField return_DamageCosts;
	@FXML
	private CheckBox return_IsRoadStarMember;
	@FXML
	private Label return_AccumulatedPointsLabel;
	@FXML
	private Label return_MemberPoints;
	@FXML
	private Label return_MemberPointstoRedeemLabel;
	@FXML
	private ComboBox<Integer> return_MemberDaystoRedeem;
	@FXML
	private Label screen2_ErrorLabel;

	/**
	 * price break up screen UI elements
	 */
	@FXML
	private TextField return_FinalCost;
	@FXML
	private ListView<String>return_PriceBreakUp;
	@FXML
	private Label priceBreakUpScreenErrorLabel;

	/**
	 * pay by cash UI elements
	 */
	@FXML
	private TextField return_BillCost;
	@FXML 
	private TextField return_AmountbyCustomer;

	@FXML
	private Button return_CashPaymentSubmit;
	@FXML
	private Label return_CashPaymentErrorLabel;

	/**
	 * payment success
	 */
	@FXML
	private Label return_AmounttobeReturnedLabel;
	@FXML
	private TextField return_ReturnAmount;
	@FXML
	private Label return_CAD;

	/**
	 *  PaymentInfo screen
	 */
	@FXML
	private TextField return_PaymentID;

	/**
	 * Loads Initial Return Frame
	 * @PRE  InternalUser must be logged in
	 * @POST Loads the Return Frame 
	 */
	public void doReturn(){
		sceneNumber = 0;
		Navigator.loadStackPane(Navigator.ReturnInitialScreenFXML);
	}
	/**
	 * Method searchRent mapped to Action Event, searches a return using Rent ID or Rented Vehicle ID
	 * @PRE InternalUser must have pressed the Return Button 
	 * @POST InternalUser will be presented with screen to search for Rent using Rent ID or Rented Vehicle ID
	 * @param event
	 */
	@FXML
	public void searchRent(ActionEvent event){
		if((return_RentID.getLength() == 0 && return_RentedVehicleID.getLength() == 0 )){
			return_InitialScreenFieldscontainSpacesLabel.setVisible(false);
			return_InitialScreenRequiredFieldsLabel.setVisible(true);
		}
		else{
			if(return_RentID.getText().trim().contains(" ") || return_RentedVehicleID.getText().trim().contains(" ")){
				return_InitialScreenRequiredFieldsLabel.setVisible(false);
				return_InitialScreenFieldscontainSpacesLabel.setVisible(true);
			}else {
				return_InitialScreenRequiredFieldsLabel.setVisible(false);
				return_InitialScreenFieldscontainSpacesLabel.setVisible(false);
				returnLogic = new ReturnLogic();
				rentEntity = new RentEntity();
				if(return_RentID.getLength() > 0){
					try{
						if(Validator.validateStringContainsInteger(return_RentID.getText().trim())){
							if(!returnLogic.searchReturn(Integer.parseInt(return_RentID.getText().trim()))){
								rentEntity =returnLogic.searchRentWithRentid(Integer.parseInt(return_RentID.getText().trim())); 
								if(rentEntity!= null){
									returnId = Integer.parseInt(return_RentID.getText().trim());
									rentedVehicleId = rentEntity.getVehicleId();
									sceneNumber = 1;
									Navigator.loadStackPane(Navigator.ReturnSecondScreenFXML);
								}else {
									return_InitialScreenFieldscontainSpacesLabel.setText("Rent ID Not Found , try with Vehicle ID ");
									return_InitialScreenFieldscontainSpacesLabel.setVisible(true);
								}
							}else{
								return_InitialScreenFieldscontainSpacesLabel.setText("Return Already done ! ");
								return_InitialScreenFieldscontainSpacesLabel.setVisible(true);
							}
						}else{
							return_InitialScreenFieldscontainSpacesLabel.setText("Rent ID should contain only numbers");
							return_InitialScreenFieldscontainSpacesLabel.setVisible(true);
						}
					}catch(SQLException e){
						return_InitialScreenFieldscontainSpacesLabel.setText("DB Exception ! ");
						return_InitialScreenFieldscontainSpacesLabel.setVisible(true);
					}
				}else if (return_RentedVehicleID.getLength() > 0){
					if(Validator.validateStringContainsInteger(return_RentedVehicleID.getText().trim())){
						try{
							rentEntity = returnLogic.searchRentWithVehicleid(Integer.parseInt(return_RentedVehicleID.getText().trim()));
							if(rentEntity != null){
								rentedVehicleId = rentEntity.getVehicleId();
								returnId = rentEntity.getRentId();
								sceneNumber = 2;
								Navigator.loadStackPane(Navigator.ReturnSecondScreenFXML);						
							}else{
								return_InitialScreenFieldscontainSpacesLabel.setText("Vehicle not Rented , try with Return ID ");
								return_InitialScreenFieldscontainSpacesLabel.setVisible(true);
							}
						}catch (SQLException sqlE){
							return_InitialScreenFieldscontainSpacesLabel.setText("Database Exception  ");
							return_InitialScreenFieldscontainSpacesLabel.setVisible(true);
						}

					}else{
						return_InitialScreenFieldscontainSpacesLabel.setText("Rented Vehicle ID should contain only numbers");
						return_InitialScreenFieldscontainSpacesLabel.setVisible(true);
					}
				}
			}
		}		
	}

	/**
	 *  Method to show Fuel To be Filled Text Field
	 *  @PRE InternalUser must click GasTank Not Full
	 *  @POST InternalUser will be presented with a Text Field to fill the remaining Fuel
	 * @param event
	 */
	@FXML
	public void showFueltobeFilledField(ActionEvent event){
		return_FueltobeFilled.setVisible(true);
		return_fueltobeFilledLabel.setVisible(true);
	}

	/**
	 *  Method to hide Fuel To be Filled Text Field
	 *  @PRE InternalUser must click GasTank Full
	 *  @POST Text Field to fill the remaining Fuel will be hidden
	 * @param event
	 */
	@FXML
	public void hideFueltobeFilledField(ActionEvent event){
		return_FueltobeFilled.setText("0");
		return_FueltobeFilled.setVisible(false);
		return_fueltobeFilledLabel.setVisible(false);
	}

	/**
	 * Method to invoke Calculate Bill module , does validation for all fields, displays error message if validation fails 
	 * @PRE InternalUser should press Generate Bill button
	 * @POST InternalUser will be presented with price break up screen 
	 * @param event
	 * @throws ParseException
	 */
	@FXML
	public void generateBill(ActionEvent event) throws ParseException{
		screen2_ErrorLabel.setVisible(false);
		try{
			if (return_ReturnHH.getValue() == null
					|| return_ReturnMM.getValue() == null
					|| return_OdometerReading.getLength() == 0
					|| return_VehicleCondition.getLength() == 0
					|| return_DamageCosts.getLength() == 0
					|| return_DamageCosts.getLength() == 0
					|| return_FueltobeFilled.getLength() == 0) {
				screen2_ErrorLabel.setText("Fields cannot be empty !! ");
				screen2_ErrorLabel.setVisible(true);
			}else{
				if (return_OdometerReading.getLength() > 0
						&& return_VehicleCondition.getLength() > 0
						&& return_DamageCosts.getLength() > 0
						&& return_FueltobeFilled.getLength() > 0) {
					ReturnLogic returnLogic = new ReturnLogic();
					return_time =  return_ReturnHH.getValue() + ":"+return_ReturnMM.getValue();
					if((Validator.validateStringContainsInteger(return_OdometerReading.getText().trim()) && 
							(Validator.validateStringContainsDouble(return_FueltobeFilled.getText().trim())) &&
							(Validator.validateStringContainsDouble(return_DamageCosts.getText().trim()))) ){
						if(Validator.validateStringContainsDouble(return_FueltobeFilled.getText().trim())){
							return_odoReading = Integer.parseInt(return_OdometerReading.getText().trim());
							returnVehicleCondition = return_VehicleCondition.getText().trim();
							isRoadstar = return_IsRoadStarMember.selectedProperty().getValue();
							if(Validator.validateStringContainsDouble(return_DamageCosts.getText().trim())){
								damageCost = Double.parseDouble(return_DamageCosts.getText().trim());
								if (return_GasTankNotFull.selectedProperty().getValue()
										&& return_FueltobeFilled.getText().trim() != null
										&& return_FueltobeFilled.getLength() > 0) {
									gasTankNotFull = return_GasTankNotFull.selectedProperty().getValue();
									fueltobeFilled	= Double.parseDouble(return_FueltobeFilled.getText().trim());
									System.out.println("gasTankNotFull : "+ gasTankNotFull);
								}else{
									fueltobeFilled = 0.00;
								}
								if(return_odoReading < Integer.parseInt(return_RentedOdometerReading.getText().trim())){
									screen2_ErrorLabel.setText("Please check the Current Odometer reading");
									screen2_ErrorLabel.setVisible(true);
								}else{
									returnEntity = new ReturnEntity();
									String rentedDateString = (return_RentedDate.getText().trim());
									LocalDate rentedDate = LocalDate.parse(rentedDateString);
									returnEntity.setRentedDate(rentedDate);
									returnCostEntity = new ReturnCostEntity();
									returnEntity.setReturnTime(return_time);
									returnEntity.setReturnDate(LocalDate.now());
									returnEntity.setReturnOdometerReading(return_odoReading);
									returnEntity.setFuelReading(fueltobeFilled);
									returnEntity.setVehicleCondition(returnVehicleCondition);
									returnEntity.setRoadstar(isRoadstar);
									returnEntity.setDamageCost(damageCost);
									returnEntity.setRentedTime(return_RentedTime.getText().trim());
									returnEntity.setRentOdometerReading(Integer.parseInt(return_RentedOdometerReading.getText().trim()));
									returnEntity.setReserveId(reserveId);
									returnEntity.setReturnId(returnId);
									returnEntity.setDaysToRedeem(return_MemberDaystoRedeem.getValue());
									returnCostEntity = returnLogic.calculateBill(returnEntity,member,pointsPerDay);
									returnCostEntity.setTotalCost(returnCostEntity.getTotalCost());
									returnCostEntity.setFinalCost(returnCostEntity.getFinalCost());
									sceneNumber=3;
									Navigator.loadStackPane(Navigator.ReturnPriceBreakUpScreenFXML);
								}
							}else{
								screen2_ErrorLabel.setText("Check the Damage Costs Field !! ");
								screen2_ErrorLabel.setVisible(true);
							}
						}else{
							screen2_ErrorLabel.setText("Check the Fuel Quantity Field !! ");
							screen2_ErrorLabel.setVisible(true);
						}
					}else{
						screen2_ErrorLabel.setText("Only numbers are allowed !! ");
						screen2_ErrorLabel.setVisible(true);
					}
				}
			} 
		}catch(SQLException e){
			screen2_ErrorLabel.setText( "DB ERROR !! ");
			screen2_ErrorLabel.setVisible(true);
		}
	}

	/**
	 * Method to invoke payment module based on type of payment (credit card or cash)
	 * @PRE InternalUser must choose payment type and press Proceed Payment button in the price break up screen
	 * @POST InternalUser will be presented the appropriate screen based on the type of the payment
	 * @param event
	 */
	@FXML
	public void pay(ActionEvent event) {
		//System.out.println(return_PaymentType.getValue());
		try{
			if(return_PaymentType.getValue().equalsIgnoreCase("cash")){
				sceneNumber=4;
				Navigator.loadStackPane(Navigator.ReturnPayByCashScreenFXML);
			}
			if(return_PaymentType.getValue().equalsIgnoreCase("Credit Card")){
				paymentInfo = returnLogic.paybyCreditCard();
				paymentID = paymentInfo.getPaymentId();
				returnEntity.setPaymentId(paymentID);
				if(member.getStatus().equalsIgnoreCase("active") && returnEntity.getDaysToRedeem() > 0 ){
					returnLogic.updateMemberPoints(member);
				}
				returnLogic.savereturn(returnEntity);
				returnLogic.updateRentedVehicle(rentedVehicleId);
				sceneNumber=5;
				Navigator.loadStackPane(Navigator.ReturnPaymentSucessInfoFXML);			
			}
		}
		catch(SQLException e){
			e.printStackTrace();
			priceBreakUpScreenErrorLabel.setVisible(true);
			priceBreakUpScreenErrorLabel.setText("DB Error !!");
		}
		catch(Exception e1){
			e1.printStackTrace();
			priceBreakUpScreenErrorLabel.setVisible(true);
			priceBreakUpScreenErrorLabel.setText("DB Error !!");
		}
	}
	/**
	 * A method handle Cash Payment option, displays the Final Cost, Calculates the Fare to be Exchanged with the customer if any 
	 * @PRE InternalUser must have chosen payment type as Cash
	 * @POST InternalUser will be presented with the Fare to be Exchanged with the customer if any
	 * @param event
	 */
	@FXML
	public void cashPay(ActionEvent event) {
		try{
			if(return_AmountbyCustomer.getLength() == 0){
				return_CashPaymentErrorLabel.setText("Field cannot be Empty !");
				return_CashPaymentErrorLabel.setVisible(true);
			}else if(!Validator.validateStringContainsDouble(return_AmountbyCustomer.getText())){
				return_CashPaymentErrorLabel.setText("Check the input !");
				return_CashPaymentErrorLabel.setVisible(true);
			}else {
				amountGivenbyCust = Double.parseDouble(return_AmountbyCustomer.getText());
				totalamount = Double.parseDouble(return_BillCost.getText());
				if(amountGivenbyCust < totalamount){
					return_CashPaymentErrorLabel.setText(" Amount Given by customer must be greater or equal to bill cost !");
					return_CashPaymentErrorLabel.setVisible(true);
				}else{
					cashEntity = new CashEntity();
					cashEntity.setGivenAmount(amountGivenbyCust);
					cashEntity.setToatlAmount(totalamount);
					cashEntity.setPaidFor("Vehicle Return");
					cashEntity.setPaymentType("Cash");
					paymentID = returnLogic.payCashReturn(cashEntity);
					returnEntity.setPaymentId(paymentID);
					if(member.getStatus().equalsIgnoreCase("active") && returnEntity.getDaysToRedeem() > 0 ){
						returnLogic.updateMemberPoints(member);
					}
					try {
						returnLogic.savereturn(returnEntity);
					} catch (SQLException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
						return_CashPaymentErrorLabel.setText(" DB Error ! !");
						return_CashPaymentErrorLabel.setVisible(true);
					}
					returnLogic.updateRentedVehicle(rentedVehicleId);
					sceneNumber=6;
					Navigator.loadStackPane(Navigator.ReturnPaymentSucessInfoFXML);
				}
			}
		}
		catch(SQLException e){
			return_CashPaymentErrorLabel.setText("DB Error !!");
			return_CashPaymentErrorLabel.setVisible(true);
		}
		catch(Exception e1){
			return_CashPaymentErrorLabel.setText("DB Error !!");
			return_CashPaymentErrorLabel.setVisible(true);
		}
	}
	
	@FXML
	public void print(ActionEvent event){
		PDFGenerator.generateReturnReceipt(returnEntity, return_PaymentID.getText());
	}
	/**
	 * Initialize method to load all the necessary UI components before the corresponding frame loads
	 */
	@Override
	public void initialize(URL location, ResourceBundle resources) {

		DecimalFormat decimalFormatter = new DecimalFormat("#0.00");

		if(sceneNumber == 0){
			Validator.addTextLimiter(return_RentID, 10);
			Validator.addTextLimiter(return_RentedVehicleID, 6);
			returnLogic = null;
			rentEntity = null;
		}
		if(sceneNumber == 1 || sceneNumber == 2){
			try{
				Validator.addTextLimiter(return_OdometerReading, 7);
				Validator.addTextLimiter(return_DamageCosts, 7);
				Validator.addTextLimiter(return_FueltobeFilled, 5);
				return_RentedDate.setText(rentEntity.getRentDate().toString());
				reserveId = rentEntity.getReserveId();
				ReservationEntity reservationEntity = new ReservationEntity();
				System.out.println(rentEntity.getReserveId());
				reservationEntity	= returnLogic.fetchReservationDetails(rentEntity.getReserveId());
				if(reservationEntity != null){
				String custPhoneNumber = null;
				custPhoneNumber = reservationEntity.getPhoneNumber().trim();
				member = new MembershipEntity();
				member = returnLogic.getMembershipDetails(custPhoneNumber);
				if(member.getStatus().equalsIgnoreCase("active")){
					return_AccumulatedPointsLabel.setVisible(true);
					return_MemberPoints.setVisible(true);
					return_MemberPoints.setText(member.getPoints().toString());
					return_MemberPointstoRedeemLabel.setVisible(true);
					return_MemberDaystoRedeem.setVisible(true);
					int days = LocalDate.now().getDayOfYear()- rentEntity.getRentDate().getDayOfYear();
					int availablePoints=member.getPoints();
					if(reservationEntity.getVehicleType().equalsIgnoreCase(Constants.VEHICLE_TYPE_PREMIUM) || 
							reservationEntity.getVehicleType().equalsIgnoreCase(Constants.VEHICLE_TYPE_ECONOMY))
					{
						pointsPerDay = Constants.POINTS_PER_DAY_PREMIUM_EC0N0MY;
					}
					else{
						pointsPerDay = Constants.POINTS_PER_DAY_OTHERS;
					}
					int pointsbyDays = availablePoints/pointsPerDay;
					if(pointsbyDays > days){
						pointsbyDays=days;
					}
					List<Integer> numOfDays= new ArrayList<>();
					numOfDays.add(0);
					for(int i=1;i<=pointsbyDays;i++){
						numOfDays.add(i);
					}
					return_MemberDaystoRedeem.setValue(numOfDays.get(0));
					return_MemberDaystoRedeem.getItems().addAll(numOfDays);
				}else{
					return_AccumulatedPointsLabel.setVisible(false);
					return_MemberPoints.setVisible(false);
					return_MemberPoints.setText(member.getPoints().toString());
					return_MemberPointstoRedeemLabel.setVisible(false);
					return_MemberDaystoRedeem.setVisible(false);
					return_MemberDaystoRedeem.setValue(0);
				}
				String rentedTime = rentEntity.getRentTime().substring(0,(rentEntity.getRentTime().length()-3));
				return_RentedTime.setText(rentedTime);
				return_RentedOdometerReading.setText(new Integer(rentEntity.getOdometerReading()).toString());
				return_DamageCosts.setText("0.00");
				return_FueltobeFilled.setText("0.00");
				}
				else{
					System.out.println("Reservation returned null");
				}
			}catch(SQLException sqe){
				sqe.printStackTrace();
			}
		}
		if(sceneNumber == 3){
			return_FinalCost.setText(String.valueOf(decimalFormatter.format(returnCostEntity.getFinalCost())));
			String additionalEquipment = " ";
			if(returnEntity.getEquipList()!=null && returnEntity.getEquipList().size() > 0){
				for(AdditionalEquipment eqp : returnEntity.getEquipList()){
					//System.out.println(eqp.getAdditionalEquipmentName()+eqp.getHourlyRate()+"\t"+eqp.getDailyRate());
					//additionalEquipment = "\n"+additionalEquipment+eqp.getAdditionalEquipmentName()+" Hourly Rate : "+eqp.getHourlyRate()+" CAD "+"\t Daily Rate"+eqp.getDailyRate()+" CAD "+"\n";
					additionalEquipment = "\n"+additionalEquipment+eqp.getAdditionalEquipmentName()+" ; "+"\n";
				}
			}else{
				additionalEquipment = "NA";
			}
			List<String> values =  Arrays.asList(		
					"Rental Cost 	: "+ String.valueOf(decimalFormatter.format(returnEntity.getRentalCost())) + " CAD ",
					"Insurance Cost : "+ String.valueOf(decimalFormatter.format(returnEntity.getInsCost())) + " CAD ",
					"Deducted Insurance Cost : "+ String.valueOf(decimalFormatter.format(returnEntity.getDedInsCost())) + " CAD ",
					"Additional Equipments Rented : "+ additionalEquipment.trim(),
					"Additional Equipment Cost 	 : " + String.valueOf(decimalFormatter.format(returnEntity.getAdditionalEquipmentCost()))+ " CAD ",
					"Penalty for Late Return 	 : " + String.valueOf(decimalFormatter.format(returnEntity.getMiscCharges()))+" CAD ",
					"Penalty for Extra Miles 	 : " + String.valueOf(decimalFormatter.format(returnEntity.getFine())) + " CAD ",
					"Penalty for Damage          : " + String.valueOf(decimalFormatter.format(returnEntity.getDamageCost()))+ " CAD",
					"Penalty for not filling Gas : " + String.valueOf(decimalFormatter.format(returnEntity.getFuelCharges()))+ " CAD",
					"Tax : " + String.valueOf(decimalFormatter.format(returnEntity.getTax()))+" CAD ",
					"Total Cost : "+ String.valueOf(decimalFormatter.format(returnEntity.getTotalCost()))+" CAD",
					"Final Cost : "+String.valueOf(decimalFormatter.format(returnEntity.getFinalCost()))+" CAD"
					);  
			return_PriceBreakUp.setItems(FXCollections.observableList(values));
		}
		if(sceneNumber == 4){
			/**
			 * Cash
			 */
			return_BillCost.setText(String.valueOf(Validator.formatDoubleWithRound(returnCostEntity.getFinalCost())));
			Validator.addTextLimiter(return_AmountbyCustomer, 8);
		}

		if(sceneNumber == 5){
			/*
			 * Credit Card
			 */
			return_PaymentID.setText(String.valueOf(paymentInfo.getPaymentId()));
		}

		if(sceneNumber == 6){
			if(amountGivenbyCust > 0){
				return_PaymentID.setText(String.valueOf((paymentID)));
				return_ReturnAmount.setText(String.valueOf(decimalFormatter.format(amountGivenbyCust - totalamount)));
				return_AmounttobeReturnedLabel.setVisible(true);
				return_ReturnAmount.setVisible(true);
				return_CAD.setVisible(true);
			}
		}
	}
}
